package com.cssw.fyzb.busi.service.turntable;

import com.cssw.fyzb.core.dao.acct.GzAddPriceDao;
import com.cssw.fyzb.core.dao.turntable.*;
import com.cssw.fyzb.core.model.dodb.*;
import com.ydn.dbframe.plugin.activerecord.Page;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.math.BigDecimal;
import java.util.List;

@Service
public class TurntableServiceImpl implements TurntableService{

    @Autowired
    private GzAddPriceDao gzAddPriceDao;

    @Autowired
    private TurntableLogDao turntableLogDao;

    @Autowired
    private TurntableWinDao turntableWinDao;

    @Autowired
    private TurnableDao turnableDao;

    @Autowired
    private TurntableNumPriceDao turntableNumPriceDao;

    @Autowired
    private TurntableNumPriceLogDao turntableNumPriceLogDao;

    @Override
    public BigDecimal getAddPriceToday(Long userId) {
        return gzAddPriceDao.getAddPriceToday(userId);
    }

    @Override
    public BigDecimal getTurnAddPriceToday(Long userId) {
        return gzAddPriceDao.sumTodayAddPriceByTaskType(userId, GzAddPrice.TASK_TYPE_TURNTABLE);
    }

    @Override
    public Integer getTurnNumToday(Long userId) {
        return turntableLogDao.getTurnNumToday(userId);
    }

    @Override
    public List<Turntable> findAll() {
        return turnableDao.findAll();
    }

    @Override
    public Page<TurntableLog> getTurntableLog(Long userId) {
        return turntableLogDao.getTurntableLog(userId);
    }

    @Override
    public Long addTurnLog(Long userId, Long turntableId, String price, String turntableName, String payType, String win) {
        return turntableLogDao.addTurnLog(userId,turntableId,price,turntableName,payType,win);
    }

    @Override
    public Long addTurnWinLog(Long logId, Long userId, Long turntableId, String type, String turntableName, String thumb, String status) {
        return turntableWinDao.addTurnWinLog(logId, userId, turntableId, type, turntableName, thumb, status);
    }

    @Override
    public TurntableWin getTurnAgainWinLog(Long userId) {
        return turntableWinDao.getTurnAgainWinLog(userId);
    }

    @Override
    public void updateTurnAgainWinLog(TurntableWin turntableWin) {
        turntableWinDao.updateTurnAgainWinLog(turntableWin);
    }

    @Override
    public Page<GzAddPrice> getGzAddPrice(Long userId) {
        return gzAddPriceDao.getGzAddPrice(userId);
    }

    @Override
    public List<TurntableNumPrice> getTurntableNumPrice() {
        return turntableNumPriceDao.findAll();
    }

    @Override
    public TurntableNumPrice getTurnNumPriceByNum(Integer num) {
        return turntableNumPriceDao.getByNum(num);
    }

    @Override
    public TurntableNumPriceLog getTurnNumPriceLog(Long userId){
        return turntableNumPriceLogDao.getTurnNumPriceLog(userId);
    }

    @Override
    public void updateLog(TurntableNumPriceLog log){
        turntableNumPriceLogDao.updateLog(log);
    }

    @Override
    public  Long saveLog(Long userId, Integer num, BigDecimal price){
        return turntableNumPriceLogDao.saveLog(userId, num, price);
    }
}
